<!DOCTYPE html>
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="apple-mobile-web-app-capable" content="no">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="format-detection" content="telephone=no,email=no">
    <meta name="apple-mobile-web-app-status-bar-style" content="white">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>请您进行人机验证</title>
</head>
<body style="text-align: center;"><br>
<h3 style="font-size: 30px;">请完成下面验证后访问</h3>
<p>当前IP:<span style="color: red;" th:text="${ip}"></span>&nbsp;访问异常</p>
<center>
    <div id="vaptchaContainer" style="width: 300px;">
        <div class="vaptcha-init-main">
            <div class="vaptcha-init-loading">
                <a href="/" target="_blank">
                    <img src="https://cdn.vaptcha.com/vaptcha-loading.gif"/>
                </a>
                <span class="vaptcha-text">Vaptcha启动中...</span>
            </div>
        </div>
    </div>
</center>
</body>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdn.vaptcha.com/v2.js"></script>
<script src="https://cdn.bootcss.com/layer/2.3/layer.js"></script>
<script th:inline="javascript">
    vaptcha({
        vid: '[(${config.capVid})]',
        type: 'embed',
        scene: '[(${s})]',
        container: '#vaptchaContainer'
    }).then(function (vaptchaObj) {
        vaptchaObj.render();
        vaptchaObj.listen('pass', function () {
            $.post("/kaptcha/verfy",
                {"vrifyCode": vaptchaObj.getToken(), "sign": "[(${sign})]"},
                function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 16, shade: 0.01, time: 15000});
                        setTimeout(function () {
                            window.location = data.ret_url;
                        }, 200);
                    } else {
                        alert(data.msg);
                        window.location.reload();
                    }
                }, "json");
        })
    });
</script>
</html>